#include "widget.h"
#include "ui_widget.h"
#include<QMouseEvent>
#include<QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::mousePressEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        qDebug()<<"mousePressEvent 按下左键";
    }
}

bool Widget::event(QEvent *event)
{
    //单击双击都拦截
    if(event->type()==QEvent::MouseButtonPress||event->type()==QEvent::MouseButtonDblClick)
    {
        qDebug()<<"event 中鼠标按下";
        return true;//返回true，代表不向下派发
    }
    //正常派发
    return QWidget::event(event);
}
